import {d_玩家英雄} from "xlsx/单位/玩家英雄";
import {l_选择英雄站位} from "../_sl_editor/l_选择英雄站位";
import PlayerUtil from "@/PlayerUtil";
import UnitUtil from "@/UnitUtil";
import CameraUtil from "@/CameraUtil";
import ActorAbilityUtil from "@/ActorAbilityUtil";

export default class 选择英雄 {
    static 隐藏英雄: unit = null;


    constructor() {
        选择英雄.创建预选英雄();
        CameraUtil.moveCamera2xy(l_选择英雄站位[7].x, l_选择英雄站位[7].y);
        se.onUnitDoubleClickSelected(e => {
            let hero = PlayerUtil.getHero(GetTriggerPlayer());
            if (IsHandle(hero)){
                return;
            }
            let unit = e.trigUnit;
            选择英雄.玩家选择英雄(unit, GetTriggerPlayer());
        })
        se.onPlayerChat("shty", (e, solarTrigger) => {
            选择英雄.玩家选择英雄(选择英雄.隐藏英雄, e.triggerPlayer);
            solarTrigger.destroy();
        })

    }

    static 创建预选英雄() {

        for (let i = 0; i < d_玩家英雄.length; i++) {
            let element = d_玩家英雄[i];
            let loc = l_选择英雄站位[i];

            let unit = CreateUnit(PlayerUtil.neutralPassivePlayer(), element.id, loc.x, loc.y, 270);
            if (i == 12) {
                选择英雄.隐藏英雄 = unit;
            }
            if (element.actorAbilList){
                let as:string[] = element.actorAbilList;
                for (let aid of as) {
                    ActorAbilityUtil.createActorAbility(aid,unit)

                }



            }

        }
    }

    static 玩家选择英雄(unit: unit, p: player) {

        SetUnitOwner(unit, p, true);
        UnitUtil.transfer(unit, -9893, 6852);
        PlayerUtil.setHero(p,unit)
        //


    }


}